class CancellationReport < ActiveRecord::Base
	belongs_to :timeslot

	validates :reason, :presence => true
	validates :comment, :presence => true
	validates :timeslot, :presence => true

  validates :reason, :numericality => true

  def date
    timeslot.date
  end

  def start_time
    timeslot.start_time_string
  end

  def end_time
    timeslot.end_time_string
  end

  def student
    timeslot.last_registration.student
  end

  def instructor
    timeslot.instructor
  end

  def display_reason
    case reason
    when 1
      'Student missing'
    when 2
      'Student unfit to drive'
    when 3
      'Student asked to cancel'
    when 4
      'Instructor unable to attend'
    when 5
      'Conditions not suitable'
    when 6
      'Other'
    else
      'Unknown reason'
    end
  end
end
